<!DOCTYPE html>
<html>
<head>

    <title>血氧测量</title>
	<titleType style="display: none">healthTest</titleType>
	<%- include('../../_global/baseLibs') %>
	<%- include('measurement.ejs') %>
    <style type="text/css">
    	.background{
			height: 220px;
			width: 100%;
			background: #fff;
		}
		
    </style>
</head>

<body>

<!-- header start -->
<header id="header" class="header-box grey fixed"  >
	<div class="header-content">
		<div class="left-tool">
			<a class="back" href="javascript:void(0)"><i class="iconfont icon-back"></i></a>
		</div>
		<div class="title">血氧测量</div>
		<div class="right-tool">
			<a class="tool-a" >提交</a>
		</div>
	</div>
</header>
<!-- header end -->

	<div class="mui-content">
		<div class="background">
			<!-- 头部导航栏 -->
			<div class="topBar">
				<div class="text">
					<a id="id_a" onclick="changeTime('testTime')">
						<img alt="" src="/static/images/back.png">
						<span class="title" >测量时间</span>
						<span id="testTime" class="time" ></span>
					</a>
				</div>
				<div class="line"></div>
			</div>

			<!-- 标尺块 -->
			<div id="xy-box" class='box'>
				<span class="title" >血氧</span>
				<div class='valueplus'>                                                                                                                           
					<div class='minus' ><a><img id="minus_img" src="/static/images/measurement/selfTest/minus.png"></a></div>
					<div class='value' ><span id='value' >0</span><span id='unit'>%</span></div>
					<div class='plus' ><a><img id="add_img" src="/static/images/measurement/selfTest/add.png"></a></div>
				</div>
				<div id='rulerWrapper'></div>
			</div>
			
		</div>
	</div>
<button id="titleBtn"   style="width: 100%;height:40px;color: #3082FF;position: fixed;bottom: 0px;;display: none;">提交</button>


	<script type="text/javascript">

        var page_oxygenMobile = (function($, page_oxygenMobile) {

            mui.init({
                swipeBack:false //启用右滑关闭功能
            });

            //尺子蓝色区域
            var greenLeft = 95;
            var greenRight = 100;
            //初始化尺子



            /*类型*/
            var cllx = '03';
            //回调函数 改变数值和颜色
            function rulerSetValue(val){
                $("#value").html(parseInt(val));
                if(val >= greenLeft && val <= greenRight ){
                    $('.valueplus .value span').css("color","#40BDFF");
                }else{
                    $('.valueplus .value span').css("color","#FDB178");
                }
            }
            /*提交血氧测量数据*/
            function submitOxygen(){
                var data = page_oxygenMobile.getData();
                $.QuickRemote.AjaxJson({
                    funcName: uri_service_tzcl_save
                    , params: data
                    , callback: function (result) {
                        $.QuickAlert.alertNormal("保存成功", {
                            callback: function(){
//                            var data = {
//                                url: url_tzcl_record + cllx
//                                ,title: "近期测量"
//                                ,type : "records_mobile"
//                            };
//                            $.QuickUrlUtils.rebackJSBridge(data);

                                var url =$.getUrl.pageUrl("measurement","selfTest_mobile");
                                var data = {refreshUrl:url,pageUrl:url};
                                $.QuickUrlUtils.refreshJSBridge(data);
                                $.pageSwitch.goToUrl("measurement","records_mobile","cllx=" + cllx);
                            }
                        })
                    }
                });
            }

            function getData() {
                /*测量时间*/
                var clsj = $("#testTime").text();
                /*血糖*/
                var xy = $("#value").text();
                return {
                    cllx: cllx
                    , clsj: clsj
                    , xy: xy
                };
            }

            var cfg_def = {
                rulerSetValue: rulerSetValue,
                submitOxygen: submitOxygen,
                getData: getData,
            }
            var sugerRuler =new MeasureRuler({
                wrapperId:"rulerWrapper",
                max:100,
                minUnit:1,// 每个刻度代表的值
                unitSet:10, // 每组刻度个数
                startValue : 50,
                mult:1, //10px
                value:95,
                greenLeft : greenLeft,
                greenRight : greenRight,
                callback:page_oxygenMobile.rulerSetValue
            })

            page_oxygenMobile.init = function(cfg){
                $.extend(page_oxygenMobile, cfg_def, cfg);

                initRule("xy-box", sugerRuler, 1);
                var date = new Date();
                $('#testTime').text(date.Format('yyyy-MM-dd HH:mm:ss'));
                $(".tool-a").on ("click", page_oxygenMobile.submitOxygen);
//                if( u.indexOf('micromessenger') != -1){
//                    $("#titleBtn").show();
//                }
                $("#titleBtn").on ("click", page_oxygenMobile.submitOxygen);
            }

            return page_oxygenMobile;
        })(jQuery, {});



	</script>
</body>

</html>